
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>nginx · Aivin开发笔记</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Aivin">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-plus/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-donate/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-local-video/video-js.min.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../styles/website.css">
        
    

        
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="redis.html" />
    
    
    <link rel="prev" href="mybatis.html" />
    

    
        <link rel="shortcut icon" href='../assets/images/favicon.ico' type="image/x-icon">
    
    
        <link rel="bookmark" href='../assets/images/favicon.ico' type="image/x-icon">
    
    
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="开发规范.html">
            
                <a href="开发规范.html">
            
                    
                    开发规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="tomcat.html">
            
                <a href="tomcat.html">
            
                    
                    框架类
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="tomcat.html">
            
                <a href="tomcat.html">
            
                    
                    tomcat
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="mysql.html">
            
                <a href="mysql.html">
            
                    
                    mysql
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="zookeeper.html">
            
                <a href="zookeeper.html">
            
                    
                    zookeeper
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="hadoop.html">
            
                <a href="hadoop.html">
            
                    
                    hadoop
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="springBoot.html">
            
                <a href="springBoot.html">
            
                    
                    springBoot
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="springcloud.html">
            
                <a href="springcloud.html">
            
                    
                    springcloud
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.7" data-path="mybatis.html">
            
                <a href="mybatis.html">
            
                    
                    mybatis
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.3.8" data-path="nginx.html">
            
                <a href="nginx.html">
            
                    
                    nginx
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.9" data-path="redis.html">
            
                <a href="redis.html">
            
                    
                    redis
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.10" data-path="swagger.html">
            
                <a href="swagger.html">
            
                    
                    swagger
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.11" data-path="jenkins.html">
            
                <a href="jenkins.html">
            
                    
                    jenkins
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >nginx</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div class="search-plus" id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#nginx"><b>1. </b>nginx</a></li><ul><li><span class="title-icon "></span><a href="#&#x5B89;&#x88C5;nginx"><b>1.1. </b>&#x5B89;&#x88C5;nginx</a></li><ul><li><span class="title-icon "></span><a href="#&#x5B89;&#x88C5;&#x4F9D;&#x8D56;"><b>1.1.1. </b>&#x5B89;&#x88C5;&#x4F9D;&#x8D56;</a></li><li><span class="title-icon "></span><a href="#&#x5B89;&#x88C5;nginx_1"><b>1.1.2. </b>&#x5B89;&#x88C5;Nginx</a></li><li><span class="title-icon "></span><a href="#nginx-&#x914D;&#x7F6E;-&#x6307;&#x5411;-tomcat"><b>1.1.3. </b>nginx &#x914D;&#x7F6E; &#x6307;&#x5411; tomcat</a></li></ul></ul></ul></div><a href="#nginx" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h1 id="nginx"><a name="nginx" class="anchor-navigation-ex-anchor" href="#nginx"><i class="fa fa-link" aria-hidden="true"></i></a>1. nginx</h1>
<p>nginx &#x7684;&#x4E3B;&#x8981;&#x4F5C;&#x7528;&#x662F;&#x53CD;&#x5411;&#x4EE3;&#x7406; &#x548C;&#x8D1F;&#x8F7D;&#x5747;&#x8861; &#x3002;</p>
<h2 id="&#x5B89;&#x88C5;nginx"><a name="&#x5B89;&#x88C5;nginx" class="anchor-navigation-ex-anchor" href="#&#x5B89;&#x88C5;nginx"><i class="fa fa-link" aria-hidden="true"></i></a>1.1. &#x5B89;&#x88C5;nginx</h2>
<p>ubuntu&#x4E0B;&#x53EF;&#x4EE5;&#x7528; apt-get &#x7684;&#x65B9;&#x5F0F;&#x8FDB;&#x884C;&#x5B89;&#x88C5;&#x3002;&#x4F46;&#x4E0D;&#x4E00;&#x5B9A;&#x662F;&#x6700;&#x65B0;&#x7248;&#x672C;&#x3002;
&#x6240;&#x4EE5;&#x4E00;&#x822C;&#x63A8;&#x8350;&#x53BB;&#x5B98;&#x7F51;&#x4E0B;&#x8F7D;&#x81EA;&#x5DF1;&#x60F3;&#x8981;&#x7248;&#x672C;&#x7684;&#x6E90;&#x7801;&#xFF0C;&#x7136;&#x540E;&#x81EA;&#x5DF1;&#x7F16;&#x8BD1;&#x5B89;&#x88C5;&#x3002;
&#x5728;linux&#x4E0A;&#x9700;&#x8981;&#x5B89;&#x88C5;&#x4E00;&#x4E9B;&#x4F9D;&#x8D56;&#x5E93;&#x624D;&#x80FD;&#x6B63;&#x786E;&#x5B89;&#x88C5;nginx&#x3002;</p>
<h3 id="&#x5B89;&#x88C5;&#x4F9D;&#x8D56;"><a name="&#x5B89;&#x88C5;&#x4F9D;&#x8D56;" class="anchor-navigation-ex-anchor" href="#&#x5B89;&#x88C5;&#x4F9D;&#x8D56;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.1. &#x5B89;&#x88C5;&#x4F9D;&#x8D56;</h3>
<pre><code class="lang-xml">apt-get update

&#x5B89;&#x88C5;gcc g++&#x7684;&#x4F9D;&#x8D56;&#x5E93;
apt-get install build-essential
apt-get install libtool

&#x5B89;&#x88C5;pcre&#x4F9D;&#x8D56;&#x5E93;
apt-get install libpcre3 libpcre3-dev

&#x5B89;&#x88C5;zlib&#x4F9D;&#x8D56;&#x5E93;
apt-get install zlib1g-dev

&#x5B89;&#x88C5;SSL&#x4F9D;&#x8D56;&#x5E93;
apt-get install openssl
</code></pre>
<h3 id="&#x5B89;&#x88C5;nginx_1"><a name="&#x5B89;&#x88C5;nginx_1" class="anchor-navigation-ex-anchor" href="#&#x5B89;&#x88C5;nginx_1"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.2. &#x5B89;&#x88C5;Nginx</h3>
<pre><code class="lang-xml">&#x53BB;&#x5B98;&#x7F51;&#x627E;&#x5230;&#x6700;&#x7248;&#x672C;&#x7684;&#x4E0B;&#x8F7D;&#x94FE;&#x63A5; &#x4E0B;&#x8F7D;&#x5E76;&#x89E3;&#x538B;
wget http://nginx.org/download/nginx-xxx.tar.gz
tar -zxvf nginx-xxx.gz

&#x8FDB;&#x5165;&#x89E3;&#x538B;&#x76EE;&#x5F55; &#x5E76;&#x914D;&#x7F6E;&#x914D;&#x7F6E;
cd nginx-xxx
./configure --prefix=/usr/local/nginx

make  //&#x7F16;&#x8BD1;
sudo make install  //&#x5B89;&#x88C5;

//&#x914D;&#x7F6E;&#x8F6F;&#x94FE;&#x63A5;
sudo ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx   

// &#x542F;&#x52A8; nginx
nginx -c /usr/local/nginx/conf/nginx.conf
(&#x6CE8;&#x610F;&#xFF1A;-c &#x6307;&#x5B9A;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x7684;&#x8DEF;&#x5F84;&#xFF0C;&#x4E0D;&#x52A0;&#x7684;&#x8BDD;&#xFF0C;nginx&#x4F1A;&#x81EA;&#x52A8;&#x52A0;&#x8F7D;&#x9ED8;&#x8BA4;&#x8DEF;&#x5F84;&#x7684;&#x914D;&#x7F6E;&#x6587;&#x4EF6;)

nginx -s stop  //&#x505C;&#x6B62;nginx
ps -ef | grep nginx   // &#x67E5;&#x770B;nginx&#x8FDB;&#x7A0B; , &#x9A8C;&#x8BC1;nginx&#x662F;&#x5426;&#x542F;&#x52A8;&#x6210;&#x529F;&#x4E86;&#x3002;

nginx&#x7684;&#x9ED8;&#x8BA4;&#x7AEF;&#x53E3;&#x662F;80 &#xFF0C;&#x53EF;&#x4EE5;&#x7528;&#x6D4F;&#x89C8;&#x5668;&#x8BBF;&#x95EE;&#x670D;&#x52A1;&#x5668;&#x5730;&#x5740; &#xFF0C;&#x5982;&#x679C;&#x6709;welcome&#x4FE1;&#x606F; &#x8BF4;&#x660E;&#x542F;&#x52A8;&#x6210;&#x529F;&#x3002;
</code></pre>
<h3 id="nginx-&#x914D;&#x7F6E;-&#x6307;&#x5411;-tomcat"><a name="nginx-&#x914D;&#x7F6E;-&#x6307;&#x5411;-tomcat" class="anchor-navigation-ex-anchor" href="#nginx-&#x914D;&#x7F6E;-&#x6307;&#x5411;-tomcat"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.3. nginx &#x914D;&#x7F6E; &#x6307;&#x5411; tomcat</h3>
<pre><code class="lang-xml">http{}&#x8282;&#x70B9;&#x4E4B;&#x95F4;&#x6DFB;&#x52A0;upstream&#x914D;&#x7F6E;&#x3002;
myServerHost &#x8FD9;&#x4E2A;&#x968F;&#x4FBF;&#x5199;&#xFF0C;&#x540E;&#x9762;&#x8981;&#x7528;&#x5230;&#x3002;
upstream myServerHost {
    server 127.0.0.1:18080;   
    server 127.0.0.1:18081;    
}

&#x7136;&#x540E;&#x5728; location &#x8282;&#x70B9;&#x4E2D;&#x914D;&#x7F6E; proxy_pass
location / {
            root   html;
            index  index.html index.htm;
            proxy_pass http://myServerHost;  
  }

&#x7136;&#x540E;&#x91CD;&#x542F; nginx &#x5373;&#x53EF;&#x3002;
</code></pre>
<footer class="page-footer"><span class="copyright">&#x65E0;&#x7248;&#x6743; &#x53EF;&#x4EE5;&#x65E0;&#x9650;&#x5236;&#x4F7F;&#x7528;&#xFF01; all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x66F4;&#x65B0;&#x65F6;&#x95F4;&#xFF1A;
2019-01-18 16:06:28
</span></footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="mybatis.html" class="navigation navigation-prev " aria-label="Previous page: mybatis">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="redis.html" class="navigation navigation-next " aria-label="Next page: redis">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"nginx","level":"1.3.8","depth":2,"next":{"title":"redis","level":"1.3.9","depth":2,"path":"chinese/redis.md","ref":"chinese/redis.md","articles":[]},"previous":{"title":"mybatis","level":"1.3.7","depth":2,"path":"chinese/mybatis.md","ref":"chinese/mybatis.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-search","search-plus","todo","anchor-navigation-ex","copy-code-button","fontsettings","tbfed-pagefooter","donate","local-video","splitter","favicon","theme-comscore","local-video"],"styles":{"website":"styles/website.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"无版权 可以无限制使用！","modify_label":"该文件更新时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"todo":{},"splitter":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"donate":{"alipay":"http://oyru0ayig.bkt.clouddn.com/201803011956_osChina_支付宝收款码.png","alipayText":"支付宝打赏","button":"打赏","title":"","wechat":"http://oyru0ayig.bkt.clouddn.com/201803011956_osChina_微信收款码.png","wechatText":"微信打赏"},"fontsettings":{"family":"sans","size":2,"theme":"sepia"},"highlight":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":true},"favicon":{"shortcut":"assets/images/favicon.ico","bookmark":"assets/images/favicon.ico"},"theme-comscore":{},"local-video":{},"copy-code-button":{},"sharing":{"all":["facebook","google","twitter","weibo","instapaper"],"facebook":true,"google":false,"instapaper":false,"twitter":true,"vk":false,"weibo":false},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"search-plus":{}},"theme":"default","author":"Aivin","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Aivin开发笔记","language":"zh-hans","gitbook":"*","description":"Aivin开发笔记"},"file":{"path":"chinese/nginx.md","mtime":"2019-01-18T08:06:28.312Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-04-12T07:41:34.135Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-search-plus/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-plus/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-copy-code-button/toggle.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-local-video/video.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

